package com.googlecode.mgwt.examples.showcase.server.jdo;

import java.util.Date;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Key;

@PersistenceCapable
public class ServiceCall {

	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Key key ;
	@Persistent
	private Date date;
	@Persistent
	private String comment;
	
	@Persistent
	private Integer addressID;
	@Persistent
	private Integer floorID;
	@Persistent
	private Integer typeID;
	@Persistent
	private String description;
	@Persistent
	private Integer buildingID;
	@Persistent
	private String reporter;
	@Persistent
	private String reporterContact;
	
	public Key getKey() {
		return key;
	}

	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	public String getComment() {
		return comment;
	}

	public void setComment(String comment) {
		this.comment = comment;
	}



	public Integer getAddressID() {
		return addressID;
	}
	public void setAddressID(Integer addressID) {
		this.addressID = addressID;
	}
	

	public Integer getFloorID() {
		return floorID;
	}

	public void setFloorID(Integer floorID) {
		this.floorID = floorID;
	}

	public Integer getTypeID() {
		return typeID;
	}

	public void setTypeID(Integer severityID) {
		this.typeID = severityID;
	}
	
	
	
	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public Integer getBuildingID() {
		return buildingID;
	}

	public void setBuildingID(Integer buildingID) {
		this.buildingID = buildingID;
	}

	public String getReporter() {
		return reporter;
	}

	public void setReporter(String reporter) {
		this.reporter = reporter;
	}

	public String getReporterContact() {
		return reporterContact;
	}

	public void setReporterContact(String reporterContact) {
		this.reporterContact = reporterContact;
	}

	@Override
	public boolean equals(Object obj) {
		if(! (obj instanceof ServiceCall)){
			return false;
		}
		ServiceCall other = (ServiceCall)obj;
		return equalOrNull(other.getBuildingID(), buildingID)&& 
				equalOrNull(other.getAddressID(),addressID) &&
				equalOrNull(other.getFloorID(),floorID)  &&
				equalOrNull(other.getTypeID(),typeID);
	}
	
	private boolean equalOrNull(Object o1, Object o2){
		if(o1==null && o2==null){
			return true;
		}
		if(o1==null ^ o2==null){
			return false;
		}
		return o1.equals(o2);
	}
	
	
	
}
